package com.leonzx.base.controller.orders;

import com.leonzx.base.config.jim.ImServerStart;
import com.leonzx.base.controller.base.BaseController;
import com.leonzx.base.service.file.FileUploadService;
import com.leonzx.base.service.system.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

/**
 * @Author:梁亮
 * @Description:
 * @Date: 2018/6/5 10:20
 */
@Controller
@RequestMapping("/orders")
public class OrdersController extends BaseController {

    @Autowired
    private OrdersService ordersService;

    @Autowired
    private ImServerStart imServerStart;

    @Autowired
    private FileUploadService fileUploadService;
    /**
     * 静态模版所在路径前缀
     */
    private String prefix = "/orders";

    /**
     * 跳转到用户管理列表
     *
     * @return
     */
    @RequestMapping("/list")
    public String list() {
        return prefix + "/list";
    }


    @RequestMapping("/selImg")
    public InputStream selImg (String path,String name){
        InputStream inputStream = ordersService.selImg(path, name);
        return inputStream;
    }

    @RequestMapping("/getImg")
    public void getImg(String key, HttpServletResponse resp) throws IOException {
        ordersService.getInputStream(key, resp);
    }
}
